/*
package com.jiazhong.servlet.controller;

import com.alibaba.fastjson.JSONArray;
import com.jiazhong.commons.bean.Emp;
import com.jiazhong.commons.util.JsonResult;
import com.jiazhong.servlet.service.EmpService;
import com.jiazhong.servlet.service.impl.EmpServiceImpl;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/emp_save")
public class EmpSaveController extends HttpServlet {

    private EmpService service;

    @Override
    public void init(ServletConfig config) throws ServletException {
        service = new EmpServiceImpl();
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        // 1. 接受用户的请求参数
        String ename = request.getParameter("ename");
        System.out.println(ename);
        String job = request.getParameter("job");
        int mgr = Integer.parseInt(request.getParameter("mgr"));
        double sal = Double.parseDouble(request.getParameter("sal"));
        double comm = Double.parseDouble(request.getParameter("comm"));
        int deptNo = Integer.parseInt(request.getParameter("deptNo"));
        Emp emp = new Emp();
        emp.setEname(ename);
        emp.setJob(job);
        emp.setSal(sal);
        emp.setComm(comm);
        emp.setDeptNo(deptNo);
        emp.setMgr(mgr);
        // 2. 调用方法
        JsonResult result = service.save(emp);
        // 3. 返回结果 数据响应
        response.setContentType("application/json;charset=utf-8");
        PrintWriter out = response.getWriter();
        out.print(JSONArray.toJSONString(result));
    }
}
*/
